
// step1
let http = require("http")

class Application {
  constructor() {
    this.callback = () => {}
  }
  use(callback){
    this.callback = callback
  }
  listen(...args){
    let server = http.createServer((req,res) => {
       this.callback(req,res)
    });
    server.listen(...args)
  }
}

let app = new Application()
app.use((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('hello ymz-koa');
})
app.listen(3000, () => {
  console.log('server running on 3000')
})
